#include "Face.h"
#include "SteeringOutput.h"

namespace Engine
{
	Face::Face():m_actualTarget(nullptr){m_target = new Agent;}

	void Face::SetTarget(Agent* t)
	{
		m_actualTarget = t;
	}

	void Face::Update(SteeringOutput* output)
	{
		Vec3 direction = m_actualTarget ->GetPos() - m_parent ->GetPos();
		if(direction.SquaredLength() == 0) return;

		*Align::m_target = *m_actualTarget;
		Align::m_target ->SetRot(atan2(direction.x, direction.z));

		Align::Update(output);
	}

	Face::~Face()
	{
		if(m_target) delete m_target;
	}
}